import React, { Component } from 'react'
import axios from 'axios';
import './index.css'
export default class YiYan extends Component {
    state = {
        msg: '',
        author: '',
        bg: 'https://api.lyiqk.cn/acg'
    }
    render() {
        let {msg, author} = this.state;
        return (
            <div  className="yiyan-con" onClick={this.update}> 
                {/** <div style={this.props.style} >*/}
                <div className="mask"></div>
                <div className="info">
                    <p>{msg}</p>
                </div>
            </div>
        )
    }
    //组件挂载完成声明周期
    componentDidMount(){
        this.update();
    }

    update = async () => {
        let result = await axios.get('http://poetry.apiopen.top/sentences');

        this.setState({
            msg: result.data.result.name,
            author: result.data.result.from
        })
    }
}
